<template>
    <div class="app-container oneSearchNoFooter">
        <div class="customContainer ">
            <!-- 搜索头 -->
            <el-form :model="formInline" :inline="true" class="demo-form-inline pull-left" size="small">
                <el-form-item>
                    <el-select filterable v-model="formInline.store_id" placeholder="请选择门店">
                        <el-option v-for="item in storeList" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-select  v-model="formInline.is_effective" filterable style="width:100px">
                        <el-option v-for="item in effective_list" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-select placeholder="选择关联状态" v-model="formInline.is_related" filterable>
                        <el-option v-for="item in type_list" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="formInline.name" placeholder="请输入套餐名称" @keyup.enter.native="searchClick">
                    </el-input>
                </el-form-item>
                <dj-button size="small" @search="searchClick" />
            </el-form>
            <el-button class="pull-right" type="primary" size="small" @click="addEditClick()">新增门票套餐</el-button>

            <!-- 表格 -->
            <el-table highlight-current-row :data="list" v-loading.body="listLoading" border size="mini">
                <el-table-column align="center" label='序号' width="50">
                    <template slot-scope="scope">
                        <span class="indexColor">{{scope.$index+1}}</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" label='套餐名称' prop="name">
                    <template slot-scope="scope">
                        <el-button type="text" @click="addEditClick(scope.row,scope.$index,'look')">{{scope.row.name}}
                        </el-button>
                    </template>
                </el-table-column>
                <el-table-column align="center" label='套餐类型'>
                    <template slot-scope="scope">
                        {{scope.row.type==1?'刷卡套餐':'无卡套餐'}}
                    </template>
                </el-table-column>
                <el-table-column align="center" label='生效时间'>
                    <template slot-scope="scope">
                        {{scope.row.effect_time}}--{{scope.row.stop_time}}
                    </template>
                </el-table-column>
                <el-table-column align="center" label='操作' width="340">
                    <template slot-scope="scope">
                        <el-button @click="addEditClick(scope.row,scope.$index,'edit')" type="primary"
                            icon="el-icon-edit" size="mini"></el-button>
                        <el-button v-if="scope.row.is_enable == 1" type="success" size="mini"
                            @click="stateClick(scope.row.id,scope.$index,0)">已启用</el-button>
                        <el-button v-else size="mini" @click="stateClick(scope.row.id,scope.$index,1)">已停用</el-button>
                        <el-button type="danger" icon="el-icon-delete" size="mini"
                            @click="delClick(scope.row.id,scope.$index)"></el-button>
                        <el-button type="primary" plain size="mini" @click="deployStoreClick(scope.row)">配置门店
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!-- 套餐新增编辑弹框 -->
            <el-dialog :close-on-click-modal="false" width="570px" :title="dialogTitle" :visible.sync="addEditDialog"
                @close="callOf('saveForm')" style="margin-top:-5vh">
                <el-form :model="saveForm" :rules="rules" ref="saveForm" class="demo-form-inline" size="small" style="position:relative"
                    :key="saveForm.id">
                    <el-form-item style="display: inline-block">
                        <el-checkbox :disabled="isDisabled" v-model="saveForm.is_re" @change="reChange">关联第三方商品
                        </el-checkbox>
                    </el-form-item>
                    <el-form-item v-if="saveForm.is_re" prop="is_collect" style="width:125px; display: inline-block">
                        <el-select :disabled="isDisabled" size="mini" filterable v-model="saveForm.is_collect"
                            @change="collectChange">
                            <el-option v-for="item in related_list" :key="item.id" :label="item.name" :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item v-if="saveForm.is_re&&saveForm.is_collect*1<3" prop="product_id"
                        style="width:125px; display: inline-block">
                        <el-input :disabled="isDisabled" size="mini" placeholder="输入商品ID" v-model="saveForm.product_id">
                        </el-input>
                    </el-form-item>
                    <el-form-item label="　套餐类型" prop="type">
                        <el-select :disabled="isDisabled||(saveForm.is_re&&saveForm.is_collect*1>0)"
                            v-model="saveForm.type" placeholder="请选择套餐类型" style="width:185px"
                            @change="saveFormTypeChange">
                            <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="　套餐名称" prop="name">
                        <el-input :disabled="isLook" placeholder="请输入套餐名称20字内" :maxlength="20" v-model="saveForm.name"
                            style="width:350px"></el-input>
                    </el-form-item>
                    <el-form-item label="　套餐价格" prop="money" v-if="saveForm.type==0" :key="saveForm.type + 123">
                        <el-input :disabled="isDisabled" type="number" onmousewheel="return false;"
                            v-model="saveForm.money" style="width:185px"></el-input>
                        <span class="indexColor">&nbsp;&nbsp; 一份套餐默认附带成人票*1 儿童票*1</span>
                    </el-form-item>
                    <el-form-item :label="saveForm.type==1 ?' 套餐以及陪同票支持卡类型':' 陪同票价格'" prop="card_type">
                        <br>
                        <el-checkbox-group class="grop-c" :disabled="isDisabled" v-model="saveForm.card_type"
                            style="margin-left:24px">
                            <el-checkbox label="1" name="card_type">临时卡　　　　</el-checkbox>
                            <span v-if="saveForm.card_type.includes('1')">
                                <el-form-item prop="coins1" v-if="saveForm.type==='1'">
                                    <el-input :disabled="isDisabled" placeholder="购买门票套餐所需币数" size="mini" type="number"
                                        onmousewheel="return false;" v-model="saveForm.coins1"></el-input>
                                </el-form-item>
                                <el-form-item prop="accompanied_coins1">
                                    <el-input :disabled="isDisabled" placeholder="购买陪同票所需币数" size="mini" type="number"
                                        onmousewheel="return false;" v-model="saveForm.accompanied_coins1"></el-input>
                                </el-form-item>
                            </span>
                            <el-form-item v-else>
                                <el-input v-if="saveForm.type==='1'" disabled size="mini"></el-input>
                                <el-input disabled size="mini"></el-input>
                            </el-form-item>
                            <br>
                            <el-checkbox label="2" name="card_type">会员卡　　　　</el-checkbox>
                            <span v-if="saveForm.card_type.includes('2')">
                                <el-form-item prop="coins2" v-if="saveForm.type==='1'">
                                    <el-input :disabled="isDisabled" placeholder="购买门票套餐所需币数" size="mini" type="number"
                                        onmousewheel="return false;" v-model="saveForm.coins2"></el-input>　　
                                </el-form-item>
                                <el-form-item prop="accompanied_coins2">
                                    <el-input :disabled="isDisabled" placeholder="购买陪同票所需币数" size="mini" type="number"
                                        onmousewheel="return false;" v-model="saveForm.accompanied_coins2"></el-input>　　
                                </el-form-item>
                            </span>
                            <el-form-item v-else>
                                <el-input v-if="saveForm.type==='1'" disabled size="mini"></el-input>
                                <el-input disabled size="mini"></el-input>
                            </el-form-item>
                            <br>
                            <el-checkbox label="3" name="card_type">精英会员卡　　</el-checkbox>
                            <span v-if="saveForm.card_type.includes('3')">
                                <el-form-item prop="coins3" v-if="saveForm.type==='1'">
                                    <el-input :disabled="isDisabled" placeholder="购买门票套餐所需币数" size="mini" type="number"
                                        onmousewheel="return false;" v-model="saveForm.coins3"></el-input>　　
                                </el-form-item>
                                <el-form-item prop="accompanied_coins3">
                                    <el-input :disabled="isDisabled" placeholder="购买陪同票所需币数" size="mini" type="number"
                                        onmousewheel="return false;" v-model="saveForm.accompanied_coins3"></el-input>　　
                                </el-form-item>
                            </span>
                            <el-form-item v-else>
                                <el-input v-if="saveForm.type==='1'" disabled size="mini"></el-input>
                                <el-input disabled size="mini"></el-input>
                            </el-form-item>
                            <br>
                            <span v-if="saveForm.type==='1'">
                                <el-checkbox label="4" name="card_type">星星卡　　　　</el-checkbox>
                                <el-form-item v-if="saveForm.card_type.includes('4')" prop="coins4">
                                    <el-input :disabled="isDisabled" placeholder="购买所需星星数" size="mini" type="number"
                                        onmousewheel="return false;" v-model="saveForm.coins4"></el-input>
                                </el-form-item>
                                <el-form-item v-else>
                                    <el-input disabled type="number" size="mini"></el-input>
                                </el-form-item>
                                <br>
                                <el-form-item>
                                    <el-checkbox label="5" name="card_type">次月季年卡</el-checkbox>
                                </el-form-item>
                                <br>
                            </span>
                            <el-checkbox label="6" name="card_type">陪同票现金支付</el-checkbox>
                            <el-form-item v-if="saveForm.card_type.includes('6')" prop="accompanied_money">
                                <el-form-item prop="accompanied_money">
                                    <el-input :disabled="isDisabled" placeholder="陪同票价格" size="mini" type="number"
                                        onmousewheel="return false;" v-model="saveForm.accompanied_money"></el-input>　　
                                </el-form-item>
                                <span class="indexColor">&nbsp;&nbsp; 套餐外单独购买成人票价格 </span>
                            </el-form-item>
                            <el-form-item v-else>
                                <el-input disabled size="mini"></el-input>
                            </el-form-item>
                        </el-checkbox-group>
                    </el-form-item>
                    <el-form-item label="　套餐说明" prop="remark">
                        <el-input :disabled="isLook" type="textarea" placeholder="请输入套餐说明150字内" :maxlength="150"
                            v-model="saveForm.remark" style="width:350px"></el-input>
                    </el-form-item>
                    <el-form-item label="　生效日期" prop="pickerDate">
                        <el-date-picker :disabled="isDisabled" v-model="saveForm.pickerDate" value-format="yyyy-MM-dd"
                            type="daterange" align="right" unlink-panels range-separator="-" start-placeholder="开始日期"
                            end-placeholder="结束日期" :picker-options="pickerOptions"></el-date-picker>
                    </el-form-item>
                    <el-checkbox v-if="saveForm.type==0" true-label="1" false-label="0" :disabled="isDisabled"
                        style="margin-left:12px;margin-right: 30px;" v-model="saveForm.is_need_auth" label="需账号授权" border></el-checkbox>
                    <el-radio style="margin-top: 11px;" :disabled="isLook" v-model="saveForm.is_print" label="1" @click.native.prevent="printRadio">打印腕带</el-radio>
                    <el-tooltip content="请先关联快盈" placement="bottom" effect="light" :disabled="isDisabled||saveForm.is_collect==1">
                        <el-radio style="margin-top: 11px;" :disabled="isLook||saveForm.is_collect!=1" v-model="saveForm.is_support_app" label="1" @click.native.prevent="appRadio">支持APP核销</el-radio>
                    </el-tooltip>
                    <el-radio :disabled="isLook" style="position:absolute;bottom:-40px;left:12px" v-model="isUsed" label="1"  @click.native.prevent="clickRadio">单笔订单使用上限</el-radio>
                    <el-form-item v-if="isUsed=='1'" prop="use_time" style="position:absolute;bottom:-65px;left:160px">
                        <el-input :disabled="isLook" style="width:125px;" size="small" v-model.number="saveForm.use_time"
                            placeholder="输入次数"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer" style="margin-top:30px">
                    <el-button v-if="!isLook" type="primary" @click="saveClick('saveForm')" size="small">保存配置
                    </el-button>
                </div>
            </el-dialog>
            <!-- 配置门店弹框 -->
            <el-dialog :close-on-click-modal="false" width="650px" title="选择门店" :visible.sync="storeDialog">
                <div v-if="storeDialog">
                    <div class="el-transfer-panel pull-left transferHeader">选择门店</div>
                    <div class="el-transfer-panel pull-right transferHeader">已选门店</div>
                </div>
                <el-transfer :props="{key: 'id', label: 'name'}" :titles="['全选', '全选']" :button-texts="['删除', '添加']"
                    filterable v-model="check_store_list" :data="t_store_list" ref="transfer"
                    :left-default-checked="leftChecked" :right-default-checked="rightChecked"
                    @change="checkStoreChange">
                </el-transfer>
                <span slot="footer" class="dialog-footer">
                    <el-button :disabled="btnDisabled" size="small" type="primary" @click="saveStoreClick">确 定
                    </el-button>
                </span>
            </el-dialog>
        </div>
    </div>
</template>

<script>
    import {
        getList,
        getPage,
        state,
        del,
        save,
        getStoreList,
        product,
        saveStore
    } from "@/api/member/ticket_meal";
    import { money, num0to99999, integer1to999 } from '@/utils/validate';
    import { pickerOptionsAfterF } from '@/utils';
    export default {
        data() {
            const validateVal = (rule, value, callback) => {
                if (!money(value)) {
                    callback(new Error('　请输入正确的金额'))
                } else {
                    callback()
                }
            }
            const validateVal1 = (rule, value, callback) => {
                if (!num0to99999(value)) {
                    callback(new Error('　输入0-99999'))
                } else {
                    callback()
                }
            }
            const validateVal2 = (rule, value, callback) => {
                if (!money(value)) {
                    callback(new Error('　请输入正确的金额，最多保留两位'))
                } else {
                    callback()
                }
            }
            const validateUse = (rule, value, callback) => {
                if (this.isUsed==1&&!integer1to999(value)) {
                    callback(new Error('请输入1-999整数'))
                } else {
                    callback()
                }
            }
            return {
                related_list: [{ id: '1', name: '关联快盈 ' }, { id: '2', name: '关联口碑' }, { id: '3', name: '代收待核' }],
                type_list: [{ id: '0', name: '未关联卡券门票套餐' }, { id: '1', name: '关联卡券门票套餐' }],
                typeList: [{ id: '0', name: '无卡套餐' }, { id: '1', name: '刷卡套餐' }],
                effective_list: [{ id: '1', name: '有效套餐' }, { id: '0', name: '失效套餐' }],
                list: null,
                storeDialog: false,
                isDisabled: true,
                isLook: false,
                listLoading: false,
                addEditDialog: false,
                collect: false,
                is_kuaiying: '',
                url: '',
                dialogTitle: '',
                isUsed: '0',
                storeList: null,
                product_info: {},
                formInline: {
                    is_related: "0",
                    store_id: "",
                    name: "",
                    is_effective: '1',
                },
                check_store_list: [],
                rightChecked: [],
                leftChecked: [],
                saveForm: {
                    id: '',
                    product_id: '',
                    type: '',
                    name: '',
                    money: '',
                    accompanied_money: '',
                    remark: '',
                    is_related: '',
                    is_collect: '',
                    effect_time: '',
                    stop_time: '',
                    is_need_auth: '',
                    pickerDate: [],
                    is_re: false,
                    card_type: [],
                    coins: [],
                    coins1: '',
                    coins2: '',
                    coins3: '',
                    coins4: '',
                    accompanied_coins: [],
                    accompanied_coins1: '',
                    accompanied_coins2: '',
                    accompanied_coins3: '',
                    accompanied_coins6: '',
                    use_time: '',
                    is_print: '1',
                    is_support_app: '0',
                },
                saveStore: {
                    store_list: [],
                    id: '',
                },
                t_store_list: [],
                btnDisabled: false,
                rules: {
                    card_type: [
                        { type: 'array', required: false, message: '请至少选择一个套餐及陪同票类型'.padStart(19, '　'), trigger: 'change' }
                    ],
                    coins1: [
                        { required: true, validator: validateVal1, trigger: 'blur' }
                    ],
                    coins2: [
                        { required: true, validator: validateVal1, trigger: 'blur' }
                    ],
                    coins3: [
                        { required: true, validator: validateVal1, trigger: 'blur' }
                    ],
                    coins4: [
                        { required: true, validator: validateVal1, trigger: 'blur' }
                    ],
                    accompanied_coins6: [
                        { required: true, validator: validateVal, trigger: 'blur' }
                    ],
                    accompanied_coins1: [
                        { required: true, validator: validateVal1, trigger: 'blur' }
                    ],
                    accompanied_coins2: [
                        { required: true, validator: validateVal1, trigger: 'blur' }
                    ],
                    accompanied_coins3: [
                        { required: true, validator: validateVal1, trigger: 'blur' }
                    ],
                    is_collect: [
                        { required: true, message: '请选中关联类型', trigger: 'change' },
                    ],
                    product_id: [
                        { required: true, message: '请输入商品ID', trigger: 'blur' },
                    ],
                    type: [
                        { required: true, message: '请选择套餐类型'.padStart(15, '　'), trigger: 'change' }
                    ],
                    name: [
                        { required: true, message: '请输入套餐名称'.padStart(15, '　'), trigger: 'blur' },
                    ],

                    remark: [
                        { required: true, message: '请输入套餐说明'.padStart(15, '　'), trigger: 'blur' }
                    ],
                    money: [
                        { required: true, validator: validateVal, trigger: 'blur' }
                    ],
                    accompanied_money: [
                        { required: true, validator: validateVal, trigger: 'blur' }
                    ],
                    pickerDate: [
                        { required: true, message: '请选择日期'.padStart(13, '　'), trigger: 'change' }
                    ],
                    use_time: [
                        { required: false, validator: validateUse, trigger: 'blur' }
                    ],
                },
                pickerOptions: pickerOptionsAfterF(),
            };
        },
        beforeRouteEnter(to, from, next) {
            next((vm) => {
                if (!vm.storeList) {
                    vm.getStore();
                }
            })
        },
        methods: {
            checkStoreChange() {
                this.btnDisabled = false;
            },
            deployStoreClick(row) {
                this.t_store_list = this.storeList.filter(item => item.name !== '全门店')
                this.btnDisabled = false;
                this.storeDialog = true;
                this.rightChecked = [];
                this.leftChecked = [];
                setTimeout(() => {
                    this.$refs.transfer.clearQuery('left');
                    this.$refs.transfer.clearQuery('right');
                }, 0);
                this.saveStore.id = row.id;
                this.saveStore.type = this.formInline.type;
                this.check_store_list = row.store_list.map(val => val.id);
            },
            saveStoreClick() {
                this.saveStore.store_list = JSON.parse(JSON.stringify(this.check_store_list));
                saveStore(this.saveStore).then(response => {
                    this.$message({ type: response.code == 1 ? 'success' : 'error', message: response.message });
                    this.fetchData();
                    this.storeDialog = false;
                }).catch(err => {
                    if (err.code) {
                        this.btnDisabled = true;
                        this.$message({ type: 'error', message: '部分所选门店已配置充值套餐，请勿重复配置，请删除', duration: 5 * 1000 });
                        this.rightChecked = err.list;
                    }
                });
            },
            getProduct(id) {
                this.product_info = {};
                product({ product_id: id }).then(response => {
                    this.product_info = response;
                });
            },
            reChange() {
                this.saveForm.is_collect = ''
                this.saveForm.product_id = ''
                this.saveForm.is_support_app = '0'
            },
            collectChange() {
                if (this.saveForm.is_collect * 1 > 0) {
                    this.saveForm.type = '0';
                }
            },
            saveFormTypeChange() {
                this.saveForm.card_type = [];
                for (let i = 1; i < 6; i++) {
                    this.saveForm['coins' + i] = ''
                }
            },
            addEditClick(row, index, look) {
                //console.log(row,999)
                switch (look) {
                    case 'look':
                        this.dialogTitle = '套餐详情';
                        break;
                    case 'edit':
                        this.dialogTitle = '修改门票类套餐';
                        break;
                    default:
                        this.dialogTitle = '新增门票类套餐';
                        break;
                }
                this.isLook = look == 'look' ? true : false;
                this.isDisabled = row ? true : false
                this.addEditDialog = true;
                this.url = row ? '/Operations_pass_business_config/pass_business_update' : '/Operations_pass_business_config/pass_business_add';
                this.saveForm.id = row ? row.id : '';
                this.saveForm.product_id = row ? row.product_id : '';
                this.saveForm.name = row ? row.name : '';
                this.saveForm.type = row ? row.type : '';
                this.saveForm.money = row ? row.money : '';
                this.saveForm.accompanied_money = row ? row.accompanied_money : '';
                this.saveForm.remark = row ? row.remark : '';
                this.saveForm.pickerDate = row ? [row.effect_time, row.stop_time] : [];
                this.saveForm.is_re = row && row.is_collect > 0 ? true : false;
                this.saveForm.is_collect = row ? row.is_collect + '' : '';
                this.saveForm.is_need_auth = row ? row.is_need_auth : '0';
                this.saveForm.card_type = row ? row.card_type || [] : [];
                this.isUsed=row?(row.use_time=="0"?"0":"1"):"0"
                this.saveForm.use_time=row?(row.use_time=="0"?"":row.use_time):""
                this.saveForm.is_print=row?row.is_print:"1"
                this.saveForm.is_support_app=row?row.is_support_app:"0"
                if (row) {
                    row.card_type.forEach((val, index) => {
                        this.saveForm['coins' + val] = row.coins[index]
                        this.saveForm['accompanied_coins' + val] = row.accompanied_coins[index]
                    })
                } else {
                    for (let i = 1; i < 7; i++) {
                        this.saveForm['coins' + i] = ''
                    }
                    for (let i = 1; i < 7; i++) {
                        this.saveForm['accompanied_coins' + i] = ''
                    }
                }
                //console.log(this.saveForm)
            },
            stateClick(id, index, is_enable) {
                let text = is_enable == '1' ? '是否启用' : '是否停用'
                this.$confirm(text, '提示', { type: 'warning' }).then(() => {
                    state({ id: id, is_enable: is_enable }).then(response => {
                        this.$message({ type: response.code == 1 ? 'success' : 'error', message: response.message });
                        if (response.code == 1) {
                            this.list[index].is_enable = is_enable == 1 ? 1 : 0
                        }
                    });
                })
            },
            clickRadio(){
                //console.log(this.isUsed)
                this.isUsed=this.isUsed==="0"?"1":"0";
                this.saveForm.use_time=this.isUsed==="0"?"":this.saveForm.use_time;
            },
            printRadio(){
                //console.log(this.isUsed)
                this.saveForm.is_print=this.saveForm.is_print==="0"?"1":"0";
            },
            appRadio(){
                //console.log(this.isUsed)
                if(this.isLook||this.saveForm.is_collect!=1){
                    return;
                }
                this.saveForm.is_support_app=this.saveForm.is_support_app==="1"?"0":"1";
            },
            saveClick(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.saveForm.coins = [];
                        this.saveForm.accompanied_coins = [];
                        this.saveForm.card_type.sort();
                        this.saveForm.accompanied_coins6=this.saveForm.accompanied_money;
                        this.saveForm.card_type.forEach((val, index) => {
                            this.saveForm.coins.push(this.saveForm['coins' + val] ? this.saveForm['coins' + val] : 0)
                            this.saveForm.accompanied_coins.push(this.saveForm['accompanied_coins' + val] ? this.saveForm['accompanied_coins' + val] : 0)
                        })
                        this.saveForm.effect_time = this.saveForm.pickerDate[0];
                        this.saveForm.stop_time = this.saveForm.pickerDate[1];
                        this.saveForm.store_id = this.formInline.store_id;
                        let data = JSON.parse(JSON.stringify(this.saveForm))
                        data.use_time=data.use_time==""?0:data.use_time;
                        save(data, this.url).then(response => {
                            this.$message({ type: response.code == 1 ? 'success' : 'error', message: response.message });
                            if (response.code == 1) {
                                this.addEditDialog = false;
                                this.fetchData();
                            }
                        });
                    }
                });
            },
            delClick(id, index) {
                this.$confirm('确认删除', '提示', { type: 'warning' }).then(() => {
                    del({ id: id }).then(response => {
                        this.$message({
                            type: response.code == 1 ? 'success' : 'error',
                            message: response.message
                        });
                        if (response.code == 1) {
                            this.list.splice(index, 1);
                        }
                    });
                })
            },
            searchClick() {
                this.fetchData()
            },
            getStore() {
                getStoreList({ category_id: 342 }).then(response => {
                    this.storeList = response;
                  let data = response.filter(res => 
                        res.id == this.$store.getters.optionId
                    )
                    if(data.length>0){
                        this.formInline.store_id = data[0].id;
                    }
                    this.fetchData();
                });
            },
            // 表单认证
            resetForm(formName) {
                this.$refs[formName].resetFields();
            },
            //关闭弹框重置
            callOf(formName) {
                this.addEditDialog = false;
                if (!this.isDisabled) {
                    this.$refs[formName].resetFields();
                }
            },
            fetchData() {
                this.listLoading = true;
                getList(this.formInline).then(response => {
                    this.list = response;
                    this.listLoading = false;
                }).catch(res=>{
                    this.listLoading=false;
                })
            },
        },
        watch:{
            "saveForm.product_id":function(val){
                this.saveForm.product_id=this.saveForm.product_id==null?"":this.saveForm.product_id.replace(/^\s+|\s+$/g, "")
            }
        }
    };
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
    .grop-c {
        .el-input {
            width: 140px;
            margin: 0 10px
        }

        .el-form-item {
            display: inline-block
        }
    }
</style>